package com.qf.servlet;

import com.qf.entity.Student;
import com.qf.util.DataUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 查询学生列表
 * description:
 * author: Ken
 * 公众号：Java架构栈
 */
@WebServlet(urlPatterns = "/querystudent")
public class QueryStudentServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse resp) throws ServletException, IOException {
        //查询学生列表
        List<Student> students = DataUtils.queryStudent();
        //将学生信息放入request作用域中
        request.setAttribute("stus", students);
//        //重定向跳转
//        resp.sendRedirect("querystudent.jsp");
        //转发
        request.getRequestDispatcher("querystudent.jsp").forward(request, resp);
    }
}
